
<style>
    #ajax-loaderdiv {position: fixed;top: 0;left: 0;width: 100%;height: 100%;z-index: 35000;background-color: rgba(0, 0, 0, 0.3);display: none;}
    .ajax-loader {position: absolute;left: 50%;top: 50%;margin-left: -16px;margin-top: -16px;display: block;}
</style>
<h4 class="form-signin-heading text-muted"><?php
    echo $control->getAjaxLink(array('name' => '功能列表', 'id' => 'showEventList'), array(
        'cooker' => 'BAEvent@showEventList'
    ));
    echo '\\';
    echo $control->getAjaxLink('设置权限首页', array(
        'cooker' => 'BAEvent@showEventHome'
    ));
    ?>\机构用户角色列表
</h4>
<div class="displayUserInfo">
    <table class="table table-striped">
        <thead>
            <tr>
                <th>用户名</th>
                <th>用户角色</th>
                <th>所属应用</th>
                <th>操作</th>
            </tr>
        </thead>
        <tbody>
            <?php
            $lastUserName = '-';
            foreach ($spaceUserRoleList as $userRoleData) {
                $userId = $userRoleData['userId'];
                $roleId = $userRoleData['roleId'];
                $user = new BUser($userId);
                $role = new BRole($roleId);
                $roleName = $role->getName();
                if ($roleName == 'all_roles')
                    continue;
                $roleFullName = $role->getFullName();
                $roleAlias = BARoleCooker::getRoleAliasByFullName($roleFullName);

                $userName = $user->getName();

                $appId = $role->appId;
                $appClass = BApp::getAppClassById($appId);
                ?>
                <?php if ($lastUserName != $userName) { ?>
                    <tr>
                        <td><?php echo $userName; ?></td>
                        <td colspan="3" >
                            <div class="pull-10">
                                <?php
                                echo $control->getAjaxLink(array(
                                    'name' => '新增用户角色', 'id' => 'addUserRole'), array(
                                    'cooker' => 'BAMembership@showAddUserRole',
                                    'userId' => $userId,
                                    'htmlOptions' => array('class' => 'btn btn-small')
                                ));
                                ?>
                            </div>
                        </td>

                    </tr>
                <?php } ?>
                <tr>
                    <td></td>
                    <td><?php
                        echo $roleAlias;
                        ?></td>
                    <td><?php
                        echo $appClass;
                        ?></td>
                    <td><?php
                        $currentUserId = Blyn::app()->getCurrentUser()->getId();
                        if ($currentUserId != $userId) {
                            echo $control->getAjaxLink(array(
                                'name' => '删除', 'id' => 'deleteUserRole'), array(
                                'roleId' => $roleId));
                        }
                        ?>
                    </td>
                </tr>
                <?php
                $lastUserName = $userName;
            }
            ?>
        </tbody>
    </table>
</div>

